# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=haskell-cairo
pkgver=0.13.8.2
pkgrel=30
pkgdesc="Binding to the cairo library for Gtk2Hs."
url="https://hackage.haskell.org/package/cairo"
license=('LGPL2.1')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'cairo' 'haskell-utf8-string')
makedepends=("haskell-gtk2hs-buildtools" "mesa" 'ghc')
conflicts=('gtk2hs-cairo')
provides=('gtk2hs-cairo')
replaces=('gtk2hs-cairo')
source=("https://hackage.haskell.org/packages/archive/cairo/${pkgver}/cairo-${pkgver}.tar.gz")
sha512sums=('bda07876a0d64421b2957e4cd77ad4f7cf2866b50530a4a1b25365a076ed6d0b8f25ef52a8b647d448b4314298ed8f157f893738e0f478c4d5941492b083a8bb')

build() {
    cd "${srcdir}/cairo-${pkgver}"

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd "${srcdir}/cairo-${pkgver}"

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
}
